<template>
      <!-- 添加新用户 -->
      <div>
     <el-dialog v-model="add" title="添加">
    <el-form :model="form">
      <el-form-item label="用户名称：" :label-width="formLabelWidth">
        <el-input v-model="name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="账号:" :label-width="formLabelWidth">
        <el-input v-model="username" autocomplete="off" />
      </el-form-item>
      <el-form-item label="密码:" :label-width="formLabelWidth">
        <el-input v-model="userpsd" autocomplete="off"  />
      </el-form-item>  
      
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="update_user"
          >确定添加</el-button
        >
      </span>
    </template>
  </el-dialog>
    </div>

      <!-- 修改用户信息  -->
     <div>
     <el-dialog v-model="dialogFormVisible" title="修改">
    <el-form :model="form">
      <el-form-item label="用户名称:" :label-width="formLabelWidth">
        <el-input v-model="name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="账号:" :label-width="formLabelWidth">
        <el-input v-model="username" autocomplete="off" />
      </el-form-item>
      <el-form-item label="  密码:" :label-width="formLabelWidth">
        <el-input v-model="userpsd" autocomplete="off"  />
      </el-form-item>

    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="update_user"
          >确定修改</el-button
        >
      </span>
    </template>
  </el-dialog>
    </div>
   
  <div>
  <el-button type="primary" @click=" onchange1">新增用户</el-button>
  <el-table :data=" tableData" style="width: 100%">
    <el-table-column label="用户名" prop="name" />
    <el-table-column label="账号" prop="usersname" />
     <el-table-column label="密码" prop="userspsd" />
    <el-table-column align="right">
      <template #default="scope">
        <el-button size="small" @click="onchange(scope)"
          >修改</el-button
        >
        <el-button
          size="small"
          type="danger"
          @click="handleDelete"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
  </div>
</template>
<script>
import axios from 'axios'
  export default {
    data() {
      return {
         formLabelWidth : '140px',
           add: false,
           editDialogVisible: true,
            dialogTableVisible :true,
           dialogFormVisible : false,
        tableData: [
        //     {
        //   name: '王小虎',
        //   username: 'ad258258',
        //   userpsd: '123456'
       
        // }
        ],
        search: ''
      }
    }, 
    mounted() {
           axios.get("/api/user/getadminuser",{
            }).then(res=>{
                // console.log(res)
             this.tableData = res.data
             console.log(this.tableData)
            
            })
       },
    methods: {
     
       onchange(){
          // console.log(scope.row.uid)
          //  console.log( uid);
        //    this.uid = scope.row.uid

            this.dialogFormVisible = true
        },
         onchange1(){
          // console.log(scope.row.uid)
          //  console.log( uid);
        //    this.uid = scope.row.uid

            this.add = true
        },
    },
  }
</script>
<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>